package com.kjtpay.design_pattern.facade;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.kjtpay.design_pattern.R;
import com.kjtpay.design_pattern.template_method.TemplateMethodActivity;

public class FacadeActivity extends AppCompatActivity {

    public static void launch(Context context) {
        if (null != context) {
            Intent intent = new Intent();
            intent.setClass(context, FacadeActivity.class);
            if (!(context instanceof Activity)) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            context.startActivity(intent);
        }
    }

    TextView infoTextView;
    Fund jijin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_facade);
        setTitle("外观模式");

        infoTextView = findViewById(R.id.textViewInfo);
        jijin = new Fund();
    }

    public void onBuyClick(View view) {
        infoTextView.setText(jijin.Buy());
    }

    public void onSellClick(View view) {
        infoTextView.setText(jijin.Sell());
    }
}